<%@page import="com.liferay.portal.model.Contact"%>
<%@page import="com.liferay.portal.model.ListTypeConstants"%>
<%@ include file="/html/common/init.jsp" %>

<%
	GeoLocation location = (GeoLocation)portletSession.getAttribute("LIFERAY_SHARED_CURRENT_LOCATION", PortletSession.APPLICATION_SCOPE);

	PortletURL redirectURL = renderResponse.createRenderURL();
	redirectURL.setParameter("jspPage", "/html/verifycontact/step2.jsp");
	
	PortletURL dialNumberURL = renderResponse.createActionURL();
	dialNumberURL.setParameter(ActionRequest.ACTION_NAME, "dialNumber");
	dialNumberURL.setParameter("redirectURL", redirectURL.toString());
	
	String label = "Mobile Number: +" + location.getIdd();
	String className = Contact.class.getName();
	
	String msg= ParamUtil.getString(request,"errorMsg");
	
%>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.js"></script>

<script type="text/javascript">
	jQuery(document).ready(function(){
		jQuery("#<portlet:namespace/>contactNumber").addClass("required");
		<%if(Validator.isNotNull(msg)){ %>
			jQuery(".portlet-msg-success").css("display","none");
		<%} %>
	}); 
	
	function registerEntered(){
		if(jQuery("#<portlet:namespace/>fm").validate().form()){
			jQuery("#<portlet:namespace/>fm").submit();
			} else {
				return false;
				}
		}
</script>	
<style type="text/css">
	label.error {
		color:red;
	}
</style>

<%if(Validator.isNotNull(msg)){ %>
	<div class="portlet-msg-info" >The given number already exists. Please enter new number.</div>
<%} %>

<h3>Enter your mobile number</h3>

<aui:form action="<%= dialNumberURL.toString() %>" method="POST" onSubmit="<%= dialNumberURL.toString() %>">

	<aui:fieldset>
		<aui:column><aui:input name="contactNumber" label="<%= label %>" inlineLabel="left" /></aui:column>
		<%-- <aui:column><aui:select label="type" name='type' listType="<%= className + ListTypeConstants.PHONE %>" inlineLabel="left" /></aui:column>
		<aui:column><aui:input name="primary" type="radio" /></aui:column>--%>
	</aui:fieldset>
	
	
	<aui:button type="button" value="Dial Me Now &raquo;" onclick="registerEntered();"/>
</aui:form>